package com.tianye.salon.dto;

import java.io.Serializable;
import java.util.Date;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;

import com.tianye.salon.model.AdminUser;




public class AdminUserFormDto implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private int id;
	@NotEmpty(message="用户名不能为空！")
	private String username;
	@NotEmpty(message="描述信息不能为空！")
	private String description;
	@Size(min=6, message="请填写最少6位密码！")
	private String pwd;
	@Size(min=6, message="请填写最少6位密码！")
	private String confirmPwd;
	@NotEmpty(message="请填写手机号！")
	@Pattern(regexp = "^1[3|4|5|7|8][0-9]\\d{8}$",message="请填写格式正确的手机号码！")
	private String email;
	//@NotNull(message="请先选择状态！")
	private Integer status=0;
	@NotNull(message="请选择角色！")
	@Min(value = 1, message="请选择角色！")
	private int roleId;
	private Date cdate;
	
	public AdminUserFormDto(){}
	
	public AdminUserFormDto(int id, String username, String description,
			String pwd, String email, Integer status,
			int roleId, Date cdate) {
		super();
		this.id = id;
		this.username = username;
		this.description = description;
		this.pwd = pwd;
		this.confirmPwd = pwd;
		this.email = email;
		this.status = status;
		this.roleId = roleId;
		this.cdate = cdate;
	}
	
	public AdminUserFormDto(int id, String username, String description,
			String pwd, String confirmPwd, String email, Integer status,
			int roleId, Date cdate) {
		super();
		this.id = id;
		this.username = username;
		this.description = description;
		this.pwd = pwd;
		this.confirmPwd = confirmPwd;
		this.email = email;
		this.status = status;
		this.roleId = roleId;
		this.cdate = cdate;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getConfirmPwd() {
		return confirmPwd;
	}
	public void setConfirmPwd(String confirmPwd) {
		this.confirmPwd = confirmPwd;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public int getRoleId() {
		return roleId;
	}
	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}
	public Date getCdate() {
		return cdate;
	}
	public void setCdate(Date cdate) {
		this.cdate = cdate;
	}
	@Override
	public String toString() {
		return "PtUserForm [id=" + id + ", username=" + username
				+ ", description=" + description + ", pwd=" + pwd
				+ ", confirmPwd=" + confirmPwd + ", email=" + email
				+ ", status=" + status + ", roleId=" + roleId + ", cdate="
				+ cdate + "]";
	}
	
	/**
	 * 转换为 AdminUser 类对象
	 * @return
	 */
	public AdminUser toUser(){
		AdminUser user = new AdminUser();
		user.setId(id);
		user.setUsername(username);
		user.setPwd(pwd);
		user.setDescription(description);
		user.setEmail(email);
		if(null == status){
			user.setStatus(1);
		} else {
			user.setStatus(status);
		}
		user.setRoleId(roleId);
		user.setCdate(cdate);
		
		return user;
	}
	
}
